import aphw

def check_writeable(fn):
    def new(self, *args, **kwargs):
        if self.read_only:
            raise aphw.ReadOnlyException()
        return fn(self, *args, **kwargs)

    new.__name__ == fn.__name__
    new.__doc__ == fn.__doc__
    return new

def return_status(fn):
    def new(*args, **kwargs):
        err = fn(*args, **kwargs)
        return aphw.StatusCodes.values[err]

    new.__name__ == fn.__name__
    new.__doc__ == fn.__doc__
    return new

strerror = aphw._aphw.strerror
